/*
Navicat SQL Server Data Transfer

Source Server         : SQL Server
Source Server Version : 150000
Source Host           : 192.168.1.106:1433
Source Database       : XINTIAN_test
Source Schema         : dbo

Target Server Type    : SQL Server
Target Server Version : 150000
File Encoding         : 65001

Date: 2023-05-19 15:32:12
*/


-- ----------------------------
-- Table structure for asn_header
-- ----------------------------
DROP TABLE [dbo].[asn_header]
GO
CREATE TABLE [dbo].[asn_header] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[asn_no] nvarchar(22) NULL ,
[asn_date] datetime NULL ,
[shipped_date] datetime NULL ,
[reference_invoice] nvarchar(30) NULL ,
[shipto_name] nvarchar(60) NULL ,
[shipto_id] nvarchar(80) NULL ,
[shipfrom_name] nvarchar(60) NULL ,
[shipfrom_id] nvarchar(80) NULL ,
[estimated_date] datetime NULL 
)


GO

-- ----------------------------
-- Table structure for asn_item
-- ----------------------------
DROP TABLE [dbo].[asn_item]
GO
CREATE TABLE [dbo].[asn_item] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[header_id] nvarchar(50) NULL ,
[item_line_no] nvarchar(20) NULL ,
[buyer_item_no] nvarchar(48) NULL ,
[ti_item_no] nvarchar(48) NULL ,
[shipped_qty] nvarchar(15) NULL ,
[measure_unit] nvarchar(2) NULL ,
[po_no] nvarchar(22) NULL ,
[po_date] datetime NULL ,
[lot_num] nvarchar(30) NULL ,
[packing_list_num] nvarchar(30) NULL ,
[reference_price] decimal(18,6) NULL 
)


GO

-- ----------------------------
-- Table structure for invoice_header
-- ----------------------------
DROP TABLE [dbo].[invoice_header]
GO
CREATE TABLE [dbo].[invoice_header] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[invoice_date] datetime NULL ,
[invoice_no] nvarchar(22) NULL ,
[po_date] datetime NULL ,
[po_no] nvarchar(22) NULL ,
[transation_type] nvarchar(2) NULL ,
[currency] nvarchar(3) NULL ,
[billto_name] nvarchar(60) NULL ,
[billto_id] nvarchar(80) NULL ,
[buyer_name] nvarchar(60) NULL ,
[buyer_id] nvarchar(80) NULL ,
[remittance_name] nvarchar(60) NULL ,
[remittance_id] nvarchar(80) NULL ,
[shipto_name] nvarchar(60) NULL ,
[shipto_id] nvarchar(80) NULL ,
[IsPay] int NULL 
)


GO

-- ----------------------------
-- Table structure for invoice_item
-- ----------------------------
DROP TABLE [dbo].[invoice_item]
GO
CREATE TABLE [dbo].[invoice_item] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[header_id] nvarchar(50) NULL ,
[item_line_no] nvarchar(20) NULL ,
[invoiced_qty] nvarchar(15) NULL ,
[measure_unit] nvarchar(2) NULL ,
[unit_price] decimal(12,5) NULL ,
[buyer_item_no] nvarchar(48) NULL ,
[ti_item_no] nvarchar(48) NULL ,
[packing_list_num] nvarchar(30) NULL ,
[reference_invoice] nvarchar(30) NULL ,
[total_amount] decimal(12,5) NULL 
)


GO

-- ----------------------------
-- Table structure for ordchg_header
-- ----------------------------
DROP TABLE [dbo].[ordchg_header]
GO
CREATE TABLE [dbo].[ordchg_header] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[doc_type] nvarchar(22) NULL ,
[po_no] nvarchar(22) NULL ,
[po_change_date] datetime NULL ,
[currency] nvarchar(3) NULL ,
[buyer_name] nvarchar(60) NULL ,
[buyer_id] nvarchar(80) NULL ,
[connect_name] nvarchar(60) NULL ,
[connect_tel] nvarchar(80) NULL ,
[shipto_name] nvarchar(60) NULL ,
[shipto_id] nvarchar(80) NULL ,
[seller_name] nvarchar(60) NULL ,
[seller_id] nvarchar(80) NULL ,
[insert_time] datetime NULL DEFAULT (getdate()) 
)


GO

-- ----------------------------
-- Table structure for ordchg_item
-- ----------------------------
DROP TABLE [dbo].[ordchg_item]
GO
CREATE TABLE [dbo].[ordchg_item] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[header_id] nvarchar(50) NULL ,
[item_line_no] nvarchar(20) NULL ,
[change_status] nvarchar(20) NULL ,
[ordered_qty] nvarchar(15) NULL ,
[ordered_left_qty] nvarchar(15) NULL ,
[measure_unit] nvarchar(2) NULL ,
[unit_price] decimal(12,5) NULL ,
[buyer_item_no] nvarchar(48) NULL ,
[ti_item_no] nvarchar(48) NULL ,
[delivery_date] datetime NULL 
)


GO

-- ----------------------------
-- Table structure for ordchgrsp_ack
-- ----------------------------
DROP TABLE [dbo].[ordchgrsp_ack]
GO
CREATE TABLE [dbo].[ordchgrsp_ack] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[item_id] nvarchar(50) NULL ,
[line_item_status] nvarchar(80) NULL ,
[shipped_qty] nvarchar(15) NULL ,
[unshipped_qty] nvarchar(15) NULL ,
[estimated_date] datetime NULL ,
[delivery_date] datetime NULL ,
[measure_unit] nvarchar(2) NULL 
)


GO

-- ----------------------------
-- Table structure for ordchgrsp_header
-- ----------------------------
DROP TABLE [dbo].[ordchgrsp_header]
GO
CREATE TABLE [dbo].[ordchgrsp_header] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[po_no] nvarchar(22) NULL ,
[po_date] datetime NULL ,
[ti_order_number] nvarchar(30) NULL ,
[buyer_name] nvarchar(60) NULL ,
[buyer_id] nvarchar(80) NULL ,
[connect_name] nvarchar(60) NULL ,
[connect_tel] nvarchar(80) NULL ,
[shipto_name] nvarchar(60) NULL ,
[shipto_id] nvarchar(80) NULL ,
[seller_name] nvarchar(60) NULL ,
[seller_id] nvarchar(80) NULL ,
[insert_time] datetime NULL DEFAULT (getdate()) 
)


GO

-- ----------------------------
-- Table structure for ordchgrsp_item
-- ----------------------------
DROP TABLE [dbo].[ordchgrsp_item]
GO
CREATE TABLE [dbo].[ordchgrsp_item] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[header_id] nvarchar(50) NULL ,
[item_line_no] nvarchar(20) NULL ,
[ordered_qty] nvarchar(15) NULL ,
[left_receive_quantity] nvarchar(15) NULL ,
[measure_unit] nvarchar(2) NULL ,
[unit_price] decimal(12,5) NULL ,
[buyer_item_no] nvarchar(48) NULL ,
[ti_item_no] nvarchar(48) NULL ,
[change_type] nvarchar(60) NULL 
)


GO

-- ----------------------------
-- Table structure for order_header
-- ----------------------------
DROP TABLE [dbo].[order_header]
GO
CREATE TABLE [dbo].[order_header] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[po_no] nvarchar(22) NULL ,
[po_date] datetime NULL ,
[currency] nvarchar(3) NULL ,
[buyer_name] nvarchar(60) NULL ,
[buyer_id] nvarchar(80) NULL ,
[connect_name] nvarchar(60) NULL ,
[connect_tel] nvarchar(80) NULL ,
[shipto_name] nvarchar(60) NULL ,
[shipto_id] nvarchar(80) NULL ,
[seller_name] nvarchar(60) NULL ,
[seller_id] nvarchar(80) NULL 
)


GO

-- ----------------------------
-- Table structure for order_item
-- ----------------------------
DROP TABLE [dbo].[order_item]
GO
CREATE TABLE [dbo].[order_item] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[header_id] nvarchar(50) NULL ,
[item_line_no] nvarchar(20) NULL ,
[ordered_qty] nvarchar(15) NULL ,
[measure_unit] nvarchar(2) NULL ,
[unit_price] decimal(12,5) NULL ,
[buyer_item_no] nvarchar(48) NULL ,
[ti_item_no] nvarchar(48) NULL ,
[delivery_date] datetime NULL 
)


GO

-- ----------------------------
-- Table structure for ordrsp_ack
-- ----------------------------
DROP TABLE [dbo].[ordrsp_ack]
GO
CREATE TABLE [dbo].[ordrsp_ack] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[item_id] nvarchar(50) NULL ,
[line_item_status] nvarchar(80) NULL ,
[line_item_qty] nvarchar(15) NULL ,
[estimated_date] datetime NULL ,
[original_qty] nvarchar(15) NULL ,
[delivery_date] datetime NULL 
)


GO

-- ----------------------------
-- Table structure for ordrsp_header
-- ----------------------------
DROP TABLE [dbo].[ordrsp_header]
GO
CREATE TABLE [dbo].[ordrsp_header] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[po_no] nvarchar(22) NULL ,
[po_date] datetime NULL ,
[ti_order_no] nvarchar(22) NULL ,
[ti_order_date] datetime NULL ,
[currency] nvarchar(3) NULL ,
[buyer_name] nvarchar(60) NULL ,
[buyer_id] nvarchar(80) NULL ,
[connect_name] nvarchar(60) NULL ,
[connect_tel] nvarchar(80) NULL ,
[shipto_name] nvarchar(60) NULL ,
[shipto_id] nvarchar(80) NULL ,
[seller_name] nvarchar(60) NULL ,
[seller_id] nvarchar(80) NULL ,
[message] nvarchar(255) NULL 
)


GO

-- ----------------------------
-- Table structure for ordrsp_item
-- ----------------------------
DROP TABLE [dbo].[ordrsp_item]
GO
CREATE TABLE [dbo].[ordrsp_item] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[header_id] nvarchar(50) NULL ,
[item_line_no] nvarchar(20) NULL ,
[ordered_qty] nvarchar(15) NULL ,
[measure_unit] nvarchar(2) NULL ,
[unit_price] decimal(12,5) NULL ,
[buyer_item_no] nvarchar(48) NULL ,
[ti_item_no] nvarchar(48) NULL 
)


GO

-- ----------------------------
-- Table structure for remittance_detail
-- ----------------------------
DROP TABLE [dbo].[remittance_detail]
GO
CREATE TABLE [dbo].[remittance_detail] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[header_id] nvarchar(50) NULL ,
[reference_type] nvarchar(3) NULL ,
[reference_num] nvarchar(30) NULL ,
[monetary_amount] decimal(16,5) NULL ,
[invoice_or_credit_date] datetime NULL 
)


GO

-- ----------------------------
-- Table structure for remittance_header
-- ----------------------------
DROP TABLE [dbo].[remittance_header]
GO
CREATE TABLE [dbo].[remittance_header] (
[id] nvarchar(50) NOT NULL ,
[status] int NULL ,
[total_monetary_amount] decimal(16,5) NULL ,
[flag_code] nvarchar(22) NULL ,
[payment_code] nvarchar(22) NULL ,
[orgin_dfi_qualifier] nvarchar(2) NULL ,
[orgin_dfi_id] nvarchar(12) NULL ,
[orgin_account_num] nvarchar(35) NULL ,
[receive_dfi_qualifier] nvarchar(2) NULL ,
[receive_dfi_id] nvarchar(12) NULL ,
[receive_account_num] nvarchar(35) NULL ,
[payment_effective_date] datetime NULL ,
[trace_num] nvarchar(15) NULL ,
[bank_name] nvarchar(60) NULL ,
[payee_name] nvarchar(60) NULL ,
[payer_name] nvarchar(60) NULL ,
[assigned_num] nvarchar(6) NULL ,
[buyer_name] nvarchar(60) NULL ,
[buyer_id] nvarchar(80) NULL ,
[payer_id] nvarchar(80) NULL ,
[payment_date] datetime NULL 
)


GO

-- ----------------------------
-- Table structure for TiItemList
-- ----------------------------
DROP TABLE [dbo].[TiItemList]
GO
CREATE TABLE [dbo].[TiItemList] (
[id] int NOT NULL IDENTITY(1,1) ,
[buyer_item_no] varchar(200) NULL ,
[ti_item_no] varchar(200) NULL ,
[min_package_num] int NULL ,
[cur_price] decimal(18,5) NULL 
)


GO

-- ----------------------------
-- Indexes structure for table asn_header
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table asn_header
-- ----------------------------
ALTER TABLE [dbo].[asn_header] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table asn_item
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table asn_item
-- ----------------------------
ALTER TABLE [dbo].[asn_item] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table invoice_header
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table invoice_header
-- ----------------------------
ALTER TABLE [dbo].[invoice_header] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table invoice_item
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table invoice_item
-- ----------------------------
ALTER TABLE [dbo].[invoice_item] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table ordchg_header
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ordchg_header
-- ----------------------------
ALTER TABLE [dbo].[ordchg_header] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table ordchg_item
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ordchg_item
-- ----------------------------
ALTER TABLE [dbo].[ordchg_item] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table ordchgrsp_ack
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ordchgrsp_ack
-- ----------------------------
ALTER TABLE [dbo].[ordchgrsp_ack] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table ordchgrsp_header
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ordchgrsp_header
-- ----------------------------
ALTER TABLE [dbo].[ordchgrsp_header] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table ordchgrsp_item
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ordchgrsp_item
-- ----------------------------
ALTER TABLE [dbo].[ordchgrsp_item] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table order_header
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table order_header
-- ----------------------------
ALTER TABLE [dbo].[order_header] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table order_item
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table order_item
-- ----------------------------
ALTER TABLE [dbo].[order_item] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table ordrsp_ack
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ordrsp_ack
-- ----------------------------
ALTER TABLE [dbo].[ordrsp_ack] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table ordrsp_header
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ordrsp_header
-- ----------------------------
ALTER TABLE [dbo].[ordrsp_header] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table ordrsp_item
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table ordrsp_item
-- ----------------------------
ALTER TABLE [dbo].[ordrsp_item] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table remittance_detail
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table remittance_detail
-- ----------------------------
ALTER TABLE [dbo].[remittance_detail] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table remittance_header
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table remittance_header
-- ----------------------------
ALTER TABLE [dbo].[remittance_header] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Indexes structure for table TiItemList
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table TiItemList
-- ----------------------------
ALTER TABLE [dbo].[TiItemList] ADD PRIMARY KEY ([id])
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[asn_item]
-- ----------------------------
ALTER TABLE [dbo].[asn_item] ADD FOREIGN KEY ([header_id]) REFERENCES [dbo].[asn_header] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[invoice_item]
-- ----------------------------
ALTER TABLE [dbo].[invoice_item] ADD FOREIGN KEY ([header_id]) REFERENCES [dbo].[invoice_header] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[ordchg_item]
-- ----------------------------
ALTER TABLE [dbo].[ordchg_item] ADD FOREIGN KEY ([header_id]) REFERENCES [dbo].[ordchg_header] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[ordchgrsp_ack]
-- ----------------------------
ALTER TABLE [dbo].[ordchgrsp_ack] ADD FOREIGN KEY ([item_id]) REFERENCES [dbo].[ordchgrsp_item] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[ordchgrsp_item]
-- ----------------------------
ALTER TABLE [dbo].[ordchgrsp_item] ADD FOREIGN KEY ([header_id]) REFERENCES [dbo].[ordchgrsp_header] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[order_item]
-- ----------------------------
ALTER TABLE [dbo].[order_item] ADD FOREIGN KEY ([header_id]) REFERENCES [dbo].[order_header] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[ordrsp_ack]
-- ----------------------------
ALTER TABLE [dbo].[ordrsp_ack] ADD FOREIGN KEY ([item_id]) REFERENCES [dbo].[ordrsp_item] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO
ALTER TABLE [dbo].[ordrsp_ack] ADD FOREIGN KEY ([item_id]) REFERENCES [dbo].[ordrsp_item] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[ordrsp_item]
-- ----------------------------
ALTER TABLE [dbo].[ordrsp_item] ADD FOREIGN KEY ([header_id]) REFERENCES [dbo].[ordrsp_header] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO
ALTER TABLE [dbo].[ordrsp_item] ADD FOREIGN KEY ([header_id]) REFERENCES [dbo].[ordrsp_header] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO

-- ----------------------------
-- Foreign Key structure for table [dbo].[remittance_detail]
-- ----------------------------
ALTER TABLE [dbo].[remittance_detail] ADD FOREIGN KEY ([header_id]) REFERENCES [dbo].[remittance_header] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION
GO
